package com.soen6441.generics;
class Pair<F,S> {
    final F first;
    final S second;

    Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    static <FT,ST> Pair<FT,ST> create(FT f, ST s){
        return new Pair<>(f, s);
    }

    public static void main(String[] args) {
        Pair<String,Integer> jordan
                = new Pair<String, Integer>("Jordan",0);

        // note type inference
        // generic methods can infer types
        // constructors can not infer types
        // Java 7 has new syntax for constructor
        // type inference empty <> diamond operator
        // less verbose
        Pair<String,Integer> joyce =
                Pair.create("Joyce", 3);

        // legal but ugly
        // sometimes type inference will fail
        // you will have to do it this way
        Pair<String, Integer> troy =
                Pair.<String,Integer>create("Troy", 37);
    }
}
